package gameFight;

/**
 * 作者:TC
 * 时间:基础角色A类 18:08
 * 描述:没有bug
 */
// 定义角色A类，继承自基础角色类
public class RoleA extends Role {
    private int experience;  // 经验值
    private int level;  // 等级

    public RoleA(int health, int attack, int defense, double critRate, double shieldRate,
                 int experience, int level) {
        super(health, attack, defense, critRate, shieldRate);
        this.experience = experience;
        this.level = level;
    }

    //重写Role中的攻击力方法 计算角色A的实际攻击力
    @Override
    public int calculateAttack() {
        if (Math.random() >= critRate) {
            //当概率高于触发暴击概率时，攻击力增加50%
            return (int) (getAttack() * 1.5);  // 角色A的攻击力暴击系数为1.3
        } else {
            return getAttack();
        }
    }

    // 重写角色A受击时计算实际防御力
    @Override
    public int calculateDefense() {
        if (Math.random() >= shieldRate) {
            return (int)(getDefense() *2);  // 角色A的防御力增加10%
        } else {
            return getDefense();
        }
    }
//获取奖励的胜利方法
public void win()
{
    reward re=new reward(0.4,0.6);
    //调用获取奖励
    String rew=re.giveReward();
    //经验值相加
    this.experience += re.getExp();
    System.out.print(" ---A获得的奖励:"+rew);
    System.out.print(" ---A获得的经验值:"+re.getExp());
    System.out.print(" ----A当前的经验值:"+this.experience);
}
    //各个属性的构造方法
    public int getExperience() {
        return experience;
    }

    public void setExperience(int experience) {
        this.experience = experience;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }
}